package com.example.orchid.coordinatorlayoutdemo.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Orchid on 2015-10-28.
 */
public class NewsListEntity extends BaseEntity implements Parcelable{
    /**
     * date : 20151028
     * stories : [{"images":["http://pic1.zhimg.com/5052616f7eaa7322da10aa540f66e550.jpg"],"type":0,"id":7347055,"ga_prefix":"102809","title":"「它们都是同一个颜色嘛」「不不，那个更深一点」"},{"images":["http://pic2.zhimg.com/b6483f430aa39d16a311445256c25c49.jpg"],"type":0,"id":7355006,"ga_prefix":"102808","title":"比起咸味，你喜欢「酸」海水吗？"},{"images":["http://pic3.zhimg.com/f152f8e5ed79907d77b6023d7eb01bf2.jpg"],"type":0,"id":7358004,"ga_prefix":"102807","title":"没有低温保存，菌失去活性的活性益生菌饮品还能喝？"},{"images":["http://pic4.zhimg.com/4fbd01a0c30ba6c6bb3abc4a4aadc8c7.jpg"],"type":0,"id":7357097,"ga_prefix":"102807","title":"这种害人的「心肌梗塞十秒自救法」，别学了"},{"images":["http://pic4.zhimg.com/b46ec1e802e5a5ebb4840ada92110277.jpg"],"type":0,"id":7358161,"ga_prefix":"102807","title":"塑胶跑道成健康杀手，都是杂质惹的祸"},{"images":["http://pic2.zhimg.com/7545e790a88b5047a1d8f828ea06dc0d.jpg"],"type":0,"id":7357359,"ga_prefix":"102806","title":"瞎扯 · 如何正确地吐槽"}]
     * top_stories : [{"image":"http://pic3.zhimg.com/67070ccb4d7e1ebd7bcda0f52ee91f72.jpg","type":0,"id":7358004,"ga_prefix":"102807","title":"没有低温保存，菌失去活性的活性益生菌饮品还能喝？"},{"image":"http://pic2.zhimg.com/6ce42650fa4c6565bd9207fc6c8749bd.jpg","type":0,"id":7357970,"ga_prefix":"102721","title":"（不）正经分析《蚁人》男主就读于哪个大学，以及他为什么那么酷"},{"image":"http://pic4.zhimg.com/9144efbc3c7b614560e5bf6e9d91b203.jpg","type":0,"id":7357097,"ga_prefix":"102807","title":"这种害人的「心肌梗塞十秒自救法」，别学了"},{"image":"http://pic2.zhimg.com/8f78da1ae4f17a2704470259143e77d9.jpg","type":0,"id":7351908,"ga_prefix":"102714","title":"为什么你妈一看到你的脸，就爱唠叨？"},{"image":"http://pic2.zhimg.com/00064e4a4cc5199bea19217d23f17979.jpg","type":0,"id":7355879,"ga_prefix":"102713","title":"火腿香肠等加工肉被正式列为 I 级致癌物，少吃点还是没问题"}]
     */

    private String date;
    /**
     * images : ["http://pic1.zhimg.com/5052616f7eaa7322da10aa540f66e550.jpg"]
     * type : 0
     * id : 7347055
     * ga_prefix : 102809
     * title : 「它们都是同一个颜色嘛」「不不，那个更深一点」
     */

    private List<StoriesEntity> stories;

    public void setDate(String date) {
        this.date = date;
    }

    public void setStories(List<StoriesEntity> stories) {
        this.stories = stories;
    }

    public String getDate() {
        return date;
    }

    public List<StoriesEntity> getStories() {
        return stories;
    }

    public static class StoriesEntity {
        private int type;
        private int id;
        private String ga_prefix;
        private String title;
        private List<String> images;

        //是否仅仅是个tag
        private boolean isTag = false;

        public void setType(int type) {
            this.type = type;
        }

        public void setId(int id) {
            this.id = id;
        }

        public void setGa_prefix(String ga_prefix) {
            this.ga_prefix = ga_prefix;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public void setImages(List<String> images) {
            this.images = images;
        }

        public int getType() {
            return type;
        }

        public int getId() {
            return id;
        }

        public String getGa_prefix() {
            return ga_prefix;
        }

        public String getTitle() {
            return title;
        }

        public List<String> getImages() {
            return images;
        }

        public boolean isTag() {
            return isTag;
        }

        public void setIsTag(boolean isTag) {
            this.isTag = isTag;
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.date);
        dest.writeList(this.stories);
    }

    public NewsListEntity() {
    }

    private NewsListEntity(Parcel in) {
        this.date = in.readString();
        this.stories = new ArrayList<StoriesEntity>();
        in.readList(this.stories, StoriesEntity.class.getClassLoader());
    }

    public static final Parcelable.Creator<NewsListEntity> CREATOR = new Parcelable.Creator<NewsListEntity>() {
        public NewsListEntity createFromParcel(Parcel source) {
            return new NewsListEntity(source);
        }

        public NewsListEntity[] newArray(int size) {
            return new NewsListEntity[size];
        }
    };
}
